package demo;

import dao.StudentDao;
import model.Student;

import java.text.MessageFormat;
import java.util.List;
import java.util.Scanner;

/**
 * @author tongchen
 * @create 2022-12-29 11:08
 */
public class exer4 {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        System.out.println("请输入学生姓名");
        String name=scan.next();
        StudentDao studentDao = new StudentDao();
        List<Student> students = studentDao.selectOne(name);
        if(students==null){
            System.out.println("不存在该同学");
            return;
        }
        for (Student student : students) {
            String info = MessageFormat.format("编号: {0}\t| 学号: {1}\t| 姓名: {2}\t | " +
                            "邮箱: {3}\t| 班级编号: {4}", student.getId(), student.getSn(), student.getName(),
                    student.getEmail(), student.getClassId());
            System.out.println(info);
        }
        int delete = studentDao.delete(name);
        if(delete>0){
            System.out.println("删除成功");
        }
        else{
            System.out.println("删除失败");
        }
    }
}
